package com.ruoyi.web.controller.mf178;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mf178.domain.Mf178Order;
import com.ruoyi.mf178.service.IMf178OrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * mf178Controller
 *
 * @author ruoyi
 * @date 2025-07-14
 */
@RestController
@RequestMapping("/mf178sys/order")
public class Mf178OrderController extends BaseController {
    @Autowired
    private IMf178OrderService mf178OrderService;

    /**
     * 查询mf178列表
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mf178Order mf178Order) {
        startPage();
        List<Mf178Order> list = mf178OrderService.selectMf178OrderList(mf178Order);
        return getDataTable(list);
    }

    /**
     * 导出mf178列表
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:export')")
    @Log(title = "mf178", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Mf178Order mf178Order) {
        List<Mf178Order> list = mf178OrderService.selectMf178OrderList(mf178Order);
        ExcelUtil<Mf178Order> util = new ExcelUtil<Mf178Order>(Mf178Order.class);
        util.exportExcel(response, list, "mf178数据");
    }

    /**
     * 获取mf178详细信息
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mf178OrderService.selectMf178OrderById(id));
    }

    /**
     * 新增mf178
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:add')")
    @Log(title = "mf178", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mf178Order mf178Order) {
        return toAjax(mf178OrderService.insertMf178Order(mf178Order));
    }

    /**
     * 修改mf178
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:edit')")
    @Log(title = "mf178", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mf178Order mf178Order) {
        return toAjax(mf178OrderService.updateMf178Order(mf178Order));
    }

    /**
     * 删除mf178
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:remove')")
    @Log(title = "mf178", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mf178OrderService.deleteMf178OrderByIds(ids));
    }

    /**
     * 作废卡
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:edit')")
    @Log(title = "mf178", businessType = BusinessType.UPDATE)
    @PostMapping("/dropCard")
    public AjaxResult dropCard(@RequestBody List<Mf178Order> mf178Order) {
        return mf178OrderService.dropCard(mf178Order);
    }

    /**
     * 查询同步卡信息
     */
    @PreAuthorize("@ss.hasPermi('mf178:order:edit')")
    @Log(title = "mf178", businessType = BusinessType.UPDATE)
    @PostMapping("/syncCardStatus")
    public AjaxResult syncCardStatus(@RequestBody List<Mf178Order> mf178Order) {
        return mf178OrderService.syncCardStatus(mf178Order);

    }
}
